﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PowerCreator.LMS.Web.BBS;
using PowerCreator.LMS.BBS.Entity;
using PowerCreator.LMS.Common.Utils;
using PowerCreator.LMS.Common.Script;

public partial class sysadmin_BBSManager_EditTitleInfo : PowerCreator.LMS.Web.Base.BasePage
{
    //ManagerBBSTitleInfo objManagerBBSTitleInfo = new ManagerBBSTitleInfo();
    //ManagerBBSTitleType objManagerBBSTitleType = new ManagerBBSTitleType();
    //ManagerBBSModuleInfo objManagerBBSModuleInfo = new ManagerBBSModuleInfo();

    ManagerBBS objManagerBBS = new ManagerBBS();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitPage();
            string ThemeID = Request.QueryString["ThemeID"].ToString();
            ThemeID = Base64.Decode(ThemeID);
            ViewState.Add("ThemeID", ThemeID);

            BinderPG();
        }
    }

    protected override void InitPage()
    {
        //lbl_InfoTitle.Text = GetLanageValueByKey("lbl_AddDepartment_InfoTitle", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_Dep_Name.Text = GetLanageValueByKey("lbl_AddDepartment_Name", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_Dep_Sort.Text = GetLanageValueByKey("lbl_AddDepartment_Sort", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_Dep_Updep.Text = GetLanageValueByKey("lbl_AddDepartment_Updep", PowerCreator.LMS.Language.LanagetItemType.Page);
        //lbl_Dep_Remark.Text = GetLanageValueByKey("lbl_AddDepartment_Remark", PowerCreator.LMS.Language.LanagetItemType.Page);

        lbl_InfoTitle.Text = GetLanageValueByKey("lbl_EditTitleInfo_InfoTitle", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Bkname.Text = GetLanageValueByKey("lbl_EditTitleInfo_Bkname", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Btname.Text = GetLanageValueByKey("lbl_EditTitleInfo_Btname", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Iszhid.Text = GetLanageValueByKey("lbl_EditTitleInfo_Iszhid", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Isjiaj.Text = GetLanageValueByKey("lbl_EditTitleInfo_Isjiaj", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Istuij.Text = GetLanageValueByKey("lbl_EditTitleInfo_Istuij", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Isxians.Text = GetLanageValueByKey("lbl_EditTitleInfo_Isxians", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Isjiet.Text = GetLanageValueByKey("lbl_EditTitleInfo_Isjiet", PowerCreator.LMS.Language.LanagetItemType.Page);
        lbl_EditTitleInfo_Noto.Text = GetLanageValueByKey("lbl_EditTitleInfo_Noto", PowerCreator.LMS.Language.LanagetItemType.Page);

        lab_tishi.Text = GetLanageValueByKey("lbl_EditTitleInfo_Bttishi", PowerCreator.LMS.Language.LanagetItemType.Page);

        rdbtn_AnswerNO.Text = GetLanageValueByKey("lbl_EditTitleInfo_No", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_AnswerOK.Text = GetLanageValueByKey("lbl_EditTitleInfo_Yes", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_IsGoad_No.Text = GetLanageValueByKey("lbl_EditTitleInfo_No", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_IsGoad_Yes.Text = GetLanageValueByKey("lbl_EditTitleInfo_Yes", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_IsHead_No.Text = GetLanageValueByKey("lbl_EditTitleInfo_No", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_IsHead_Yes.Text = GetLanageValueByKey("lbl_EditTitleInfo_Yes", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_IsHot_No.Text = GetLanageValueByKey("lbl_EditTitleInfo_No", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_IsHot_Yes.Text = GetLanageValueByKey("lbl_EditTitleInfo_Yes", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_ShowNo.Text = GetLanageValueByKey("lbl_EditTitleInfo_No", PowerCreator.LMS.Language.LanagetItemType.Page);
        rdbtn_ShowOK.Text = GetLanageValueByKey("lbl_EditTitleInfo_Yes", PowerCreator.LMS.Language.LanagetItemType.Page);
        
        
           

        btn_save.Text = GetLanageValueByKey("lbl_EditTitleInfo_Save", PowerCreator.LMS.Language.LanagetItemType.Page);
        btnBack.Text = GetLanageValueByKey("lbl_EditTitleInfo_Bank", PowerCreator.LMS.Language.LanagetItemType.Page);


        base.InitPage();
    }

    private void BinderPG()
    {

        VOTheme objVOTheme = new VOTheme();

        objVOTheme = objManagerBBS.LoadTheme(int.Parse(ViewState["ThemeID"].ToString()));

        if (objVOTheme == null)
        {
            Script.ShowAndHistory(GetLanageValueByKey("web_bbs_EditTitleInfo_msg_m2", PowerCreator.LMS.Language.LanagetItemType.Page), -1);
            return;
        }
        ViewState.Add("objVOTheme", objVOTheme);

        //BBSModuleInfo objBBSModuleInfo=new BBSModuleInfo();
        VODomain objVODomain = new VODomain();

        objVODomain = objManagerBBS.LoadDomain(objVOTheme.ThemeDomainID);


        lab_TypeName.Text = objVODomain.DomainName;

        txt_TitleName.Text = objVOTheme.ThemeTitle;
        txt_Description.Text = objVOTheme.ThemeContent;
        if (objVOTheme.ThemeIsTop == 1)
        {
            rdbtn_IsGoad_Yes.Checked = true;
        }
        else
        {
            rdbtn_IsGoad_No.Checked = true;
        }
        if (objVOTheme.ThemeIsElite == 1)
        {
            rdbtn_IsHead_Yes.Checked = true;
        }
        else
        {
            rdbtn_IsHead_No.Checked = true;
        }
        if (objVOTheme.ThemeIsRecommend == 1)
        {
            rdbtn_IsHot_Yes.Checked = true;
        }
        else
        {
            rdbtn_IsHot_No.Checked = true;
        }
        if (objVOTheme.ThemeAnswerState == 1)
        {
            rdbtn_AnswerNO.Checked = true;
        }
        else
        {
            rdbtn_AnswerOK.Checked = true;
        }
        if (objVOTheme.ThemeIsVisible == 0)
        {
            rdbtn_ShowNo.Checked = true;
        }
        else
        {
            rdbtn_ShowOK.Checked = true;
        }
    }
    private bool CheckSoftData()
    {
        if (string.IsNullOrEmpty(txt_TitleName.Text.Trim()))
        {
            Script.Alert(Page, "update", GetLanageValueByKey("web_bbs_EditTitleInfo_msg_m3", PowerCreator.LMS.Language.LanagetItemType.Page));
            return false;
        }
        if (txt_TitleName.Text.Length > 30)
        {
            Script.Alert(Page, "msg", GetLanageValueByKey("web_bbs_EditTitleInfo_msg_m4", PowerCreator.LMS.Language.LanagetItemType.Page));
            return false;
        }
        return true;
    }
    protected void btn_save_Click(object sender, EventArgs e)
    {
        if (!CheckSoftData()) return;
        VOTheme info = (VOTheme)ViewState["objVOTheme"];

        info.ThemeTitle = txt_TitleName.Text;
        info.ThemeContent = txt_Description.Text;
        if (rdbtn_IsGoad_Yes.Checked)
        {
            info.ThemeIsTop = 1;
        }
        else
        {
            info.ThemeIsTop = 0;
        }
        if (rdbtn_IsHot_Yes.Checked)
        {
            info.ThemeIsRecommend = 1;
        }
        else
        {
            info.ThemeIsRecommend = 0;
        }
        if (rdbtn_IsHead_Yes.Checked)
        {
            info.ThemeIsElite = 1;
        }
        else
        {
            info.ThemeIsElite = 0;
        }
        if (rdbtn_AnswerOK.Checked)
        {
            info.ThemeAnswerState = 0;
        }
        else
        {
            info.ThemeAnswerState = 1;
        }

        if (rdbtn_ShowOK.Checked)
        {
            info.ThemeIsVisible = 1;
        }
        else
        {
            info.ThemeIsVisible = 0;
        }

        //Script.Alert(Page, "update", objManagerBBSModuleInfo.Update(info));
        if (objManagerBBS.UpdateTheme(info))
        {
            Script.Alert(this, "msg", GetLanageValueByKey("Msg_ManagerQuestion_WorkOK", PowerCreator.LMS.Language.LanagetItemType.Page));
        }
        else
        {
            Script.Alert(this, "msg", GetLanageValueByKey("Msg_ManagerQuestion_WorkNo", PowerCreator.LMS.Language.LanagetItemType.Page));
        }
        //Script.ShowAndRedirect(this, objManagerBBSTitleInfo.Update(info), "ManagerTitleInfo.aspx");

    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        string url = "ManagerTitleInfo.aspx";
        Script.RedirectURL(url);
    }
}
